/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#include "stdafx.h"
#include "S_Chrono核心.h"

//#include "chrono/ChConfig.h"
//#include "chrono/utils/ChUtilsCreators.h"
//#include "chrono/utils/ChUtilsGenerators.h"
#include "chrono/solver/ChSolverMINRES.h"


#ifdef _DEBUG 

#pragma comment(lib,"D:/U/DEV/Chrono/lib/Debug/ChronoEngine.lib")
#pragma comment(lib,"D:/U/DEV/Chrono/lib/Debug/ChronoEngine_cosimulation.lib")
//#pragma comment(lib,"D:/U/DEV/Chrono/lib/Debug/ChronoEngine_fsi.lib")
//#pragma comment(lib,"D:/U/DEV/Chrono/lib/Debug/ChronoEngine_irrlicht.lib")
//#pragma comment(lib,"D:/U/DEV/Chrono/lib/Debug/ChronoEngine_parallel.lib")
//#pragma comment(lib,"D:/U/DEV/Chrono/lib/Debug/ChronoEngine_postprocess.lib")
#pragma comment(lib,"D:/U/DEV/Chrono/lib/Debug/ChronoEngine_vehicle.lib")
#pragma comment(lib,"D:/U/DEV/Chrono/lib/Debug/ChronoModels_vehicle.lib")

#else

#pragma comment(lib,"D:/U/DEV/Chrono/lib/Release/ChronoEngine.lib")


#endif



S_Chrone物理引擎核心::S_Chrone物理引擎核心()
{
	m_PhysicalSystem = new chrono::ChSystemNSC(true, 1600, 20);
	
	//m_PhysicalSystem->SetSolverType(chrono::ChSolver::Type::SOR);
	m_PhysicalSystem->SetSolverType(chrono::ChSolver::Type::MINRES);
	m_PhysicalSystem->SetTimestepperType(chrono::ChTimestepper::Type::TRAPEZOIDAL_LINEARIZED);

	auto msolver = std::static_pointer_cast<chrono::ChSolverMINRES>(m_PhysicalSystem->GetSolver());
	msolver->SetRelTolerance(1e-20);
	msolver->SetTolerance(1e-20);
	// msolver->SetVerbose(true);
	msolver->SetDiagonalPreconditioning(true);
	
	m_PhysicalSystem->SetSolverWarmStarting(false);
	m_PhysicalSystem->SetMaxItersSolverSpeed(538);

	//auto my_ground = chrono::ChBodyEasyBox(60, 2, 60, 1.0, true, true);
	m_PhysicalSystem->DoStaticLinear();
	m_PhysicalSystem->SetTolForce(1e-10);
	m_PhysicalSystem->DoStaticNonlinear(32);
}

S_Chrone物理引擎核心::~S_Chrone物理引擎核心()
{
}






